package com.tensequare.friend.dao;

import com.tensequare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description:
 * @Date: Create in 2019/3/29 15:38
 */
public interface FriendDao extends JpaRepository<Friend,String> {
    @Query(nativeQuery = true,value = "select count(userid) from tb_friend where userid=? and friendid=?")
    public int findCount(String userid,String friendid);
    //根据userid及friendid更新好友
    @Modifying
    @Query(nativeQuery = true,value = "update tb_friend set islike=? where userid=? and friendid=?")
    public void updateLike(String islike,String userid,String friendid);
    //删除好友
    @Modifying
    @Query(nativeQuery = true,value = "delete from tb_friend where userid=? and friendid=?")
    public void deleteFriendBy(String userid,String friendid);

}
